package com.leyou.user.service.service;

import com.leyou.common.bean.PageResult;
import com.leyou.common.bean.Result;
import com.leyou.user.inter.dto.PermissionPageDTO;
import com.leyou.user.inter.dto.RoleAuthorizeDTO;
import com.leyou.user.inter.pojo.Permission;
import com.leyou.user.inter.pojo.Role;
import com.leyou.user.inter.vo.AuthorizeTreeVO;
import com.leyou.user.inter.vo.MenuVO;

import java.util.List;

/**
 * @author zqq
 * @ClassName AuthorizeService
 * @Description
 * @date 2020/3/24-17:50
 */
public interface AuthorizeService {

    /**
     * @Title: queryRoleByUserId
     * @Description: 根据用户id查询对应的角色
     * @author: zqq
     * @param uid 用户ID
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.pojo.Role>>
     * @createTime: 2020-03-24 17:56
     * @version: v.1.0
     */
    Result<List<Role>> queryRoleByUserId(Long uid);

    /**
     * @Title: queryRoleAll
     * @Description: 查询所有权限
     * @author: zqq
     * @param
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.pojo.Role>>
     * @createTime: 2020-03-24 18:56
     * @version: v.1.0
     */
    Result<List<Role>> queryRoleAll();

    /**
     * @Title: queryPermissionByRid
     * @Description: 根据角色id查询对应的权限id
     * @author: zqq
     * @param rid 角色id
     * @return: com.leyou.common.bean.Result<java.util.List<java.lang.Long>>
     * @createTime: 2020-03-24 21:44
     * @version: v.1.0
     */
    Result<List<Long>> queryPermissionByRid(Long rid);

    /**
     * @Title: queryRoleByAll
     * @Description: 查询所有的角色
     * @author: zqq
     * @param
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.pojo.Role>>
     * @createTime: 2020-03-26 10:41
     * @version: v.1.0
     */
    Result<List<Role>> queryRoleByAll();

    /**
     * @Title: updateRole
     * @Description: 新增或修改角色
     * @author: zqq
     * @param role
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-26 11:04
     * @version: v.1.0
     */
    Result updateRole(Role role);

    /**
     * @Title: updateRoleAuthorize
     * @Description: 权限分配
     * @author: zqq
     * @param dto
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-26 11:04
     * @version: v.1.0
     */
    Result updateRoleAuthorize(RoleAuthorizeDTO dto);

    /**
     * @Title: deleteRole
     * @Description: 角色的删除与恢复
     * @author: zqq
     * @param role
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-26 11:05
     * @version: v.1.0
     */
    Result deleteRole(Role role);

    /**
     * @Title: queryPermissionByPage
     * @Description: 分页查询权限
     * @author: zqq
     * @param dto
     * @return: com.leyou.common.bean.Result<com.leyou.common.bean.PageResult<com.leyou.user.inter.pojo.Permission>>
     * @createTime: 2020-03-26 14:29
     * @version: v.1.0
     */
    Result<PageResult<Permission>> queryPermissionByPage(PermissionPageDTO dto);

    /**
     * @Title: updatePermission
     * @Description: 新增或修改权限
     * @author: zqq
     * @param dto
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-26 14:29
     * @version: v.1.0
     */
    Result updatePermission(Permission dto);

    /**
     * @Title: enablePermission
     * @Description: 启用获禁用权限
     * @author: zqq
     * @param dto
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-26 14:30
     * @version: v.1.0
     */
    Result enablePermission(Permission dto);

    /**
     * @Title: queryPermissionByTree
     * @Description: 查询所有权限，并以树状结构返回
     * @author: zqq
     * @param
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.vo.AuthorizeTreeVO>>
     * @createTime: 2020-03-28 12:24
     * @version: v.1.0
     */
    Result<List<AuthorizeTreeVO>> queryPermissionByTree();

    /**
     * @Title: queryPermissionByPid
     * @Description: 根据parentId查询子权限
     * @author: zqq
     * @param pid
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.pojo.Permission>>
     * @createTime: 2020-03-29 11:56
     * @version: v.1.0
     */
    Result<List<Permission>>  queryPermissionByPid(Long pid);

    /**
     * @Title: queryPermissionById
     * @Description: 根据主键查询权限表
     * @author: zqq
     * @param id
     * @return: com.leyou.common.bean.Result<com.leyou.user.inter.pojo.Permission>
     * @createTime: 2020-03-29 21:19
     * @version: v.1.0
     */
    Result<Permission> queryPermissionById(Long id);

    /**
     * @Title: loadRedisAuthorize
     * @Description: 把所有权限存入redis
     * @author: zqq
     * @param
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-30 16:54
     * @version: v.1.0
     */
    Result loadRedisAuthorize();

    /**
     * @Title: updateRedisAuthorize
     * @Description: 更新redis中角色对应的权限
     * @author: zqq
     * @param rid
     * @param bool
     * @return: com.leyou.common.bean.Result
     * @createTime: 2020-03-30 17:26
     * @version: v.1.0
     */
    Result updateRedisAuthorize(Long rid,Boolean bool);

    /**
     * @Title: queryMenuByUser
     * @Description: 获取用户一二级菜单
     * @author: zqq
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.vo.MenuVO>>
     * @createTime: 2020-04-01 12:00
     * @version: v.1.0
     */
    Result<List<MenuVO>> queryMenuByUser();

    /**
     * @Title: queryOtherAuthorize
     * @Description: 获取二级菜单下的所有权限
     * @author: zqq
     * @param url
     * @return: com.leyou.common.bean.Result<java.util.List<com.leyou.user.inter.pojo.Permission>>
     * @createTime: 2020-04-01 12:44
     * @version: v.1.0
     */
    Result<List<Permission>> queryOtherAuthorize(String url);

}
